var express = require('express');
var router = express.Router();

// 图片上传
var multer = require("multer");
var storage = multer.diskStorage({
  destination: function (req, file, cb) {
    cb(null, './public/images/goods')
  },
  filename: function (req, file, cb) {
    var suffix = file.mimetype.split("/")[1];
    cb(null, file.fieldname + '-' + Date.now()+"."+suffix);
  }
})
var upload = multer({ storage: storage })

/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('index', { title: 'Express' });
});



router.post("/upload",upload.array("pic"),function(req,res){
  res.json({err:0,msg:"上传完毕"});
});

module.exports = router;
